home *** CD-ROM | disk | FTP | other *** search
/ 220 Jogos / 220 jogos.iso / tetris / tetron / SOURCE / container.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-13  |  4.2 KB  |  111 lines

  1. //----------------------------------------------------------------------------------------
  2. //----------------------------------------------------------------------------------------
  3. //
  4. //        Filename        :    container.h
  5. //        Description        :    Header file for Container class
  6. //        Author            :   Marnich van Rensburg (2002)
  7. //
  8. //----------------------------------------------------------------------------------------
  9. //----------------------------------------------------------------------------------------
  10.  
  11. #include "tetramino.h"
  12. #include <time.h>        // For time function
  13. #include <stdlib.h>        // For srand and rand functions
  14. #include <math.h>        // For abs()
  15.  
  16. //----------------------------------------------------------------------------------------
  17. //        External Globals
  18. //----------------------------------------------------------------------------------------
  19.  
  20. extern bool SoundActive;
  21. extern bool StarFieldActive;
  22.  
  23.  
  24. //----------------------------------------------------------------------------------------
  25. //        Constants
  26. //----------------------------------------------------------------------------------------
  27.  
  28. #ifndef CONTAINER_H
  29. #define CONTAINER_H
  30.  
  31. #define CON_WIDTH                36
  32. #define CON_HEIGHT                20
  33. #define CON_EMPTY_CELL             0
  34. #define CON_LINE_CELL             8
  35.  
  36. #define CON_ROTATION_STEP        10.0f
  37. #define CON_ROTATION_FSTEP        10.0f
  38.  
  39. #define CON_RADIUS                5.715f
  40.  
  41. //Container Actions
  42. #define CON_NONE                0
  43. #define CON_ROTATE_RIGHT        1
  44. #define CON_ROTATE_LEFT            2
  45. #define CON_CHECK_FOR_LINES        3
  46. #define CON_SHOW_LINES            4
  47. #define CON_REMOVE_LINES        5
  48. #define CON_START_NEXT            6
  49. #define CON_GAME_OVER            7
  50.  
  51.  
  52. #define CON_HOVER_MAX            1
  53.  
  54.  
  55.  
  56. //----------------------------------------------------------------------------------------
  57. //    Class Definition for Container Class
  58. //----------------------------------------------------------------------------------------
  59.  
  60. class Container
  61. {
  62.  
  63.     //---------------------- Public -------------------------
  64.  
  65.     public:
  66.  
  67.         // Data Members
  68.         float    x, y, z;                    // (OGL) (x, y, z) position of container
  69.  
  70.         // Member Funtions
  71.                 Container();                // Constructor
  72.         bool    Collision(char x, char y);    // Checks for collisions at x, y
  73.         void    DoAction();                    // (OGL) will perform the current action    
  74.         char    GetAction();                // (OGL) will start a new action if CurActive = NONE
  75.         char    GetMatrix(char x, char y);    // Returns the value of the Container cell at (x, y)
  76.         char    GetNoOfLinesFound();        // Returns No of lines found in the container
  77.         float    GetRotation();                // (OGL) Returns the current x rotation angle
  78.         bool    Inside(char x, char y);        // Checks if the (x, y) is inside the container
  79.         void    New();                        // Init/Clears the Container
  80.         bool    PlaceTet(Tetramino& ref_Tet);    // Place tetramino onto container
  81.         void    RemoveTet(Tetramino& ref_Tet);    // Removes tetramino from container
  82.         void    ResetNoOfLinesFound();        // Sets No of lines found to 0
  83.         void    RotateLeft();                // (OGL) sets new rotation angle (left) based on ROTATION_STEP 
  84.         void    RotateRight();                // (OGL) sets new rotation angle (Right) based on ROTATION_STEP 
  85.         void    SetAction(char Action);        // (OGL) will start a new action if CurActive = NONE
  86.         void    SetMatrix(char x, char y, char Data);    // Places cell data at (x, y) in the container
  87.         void    SetPos(float x, float y, float z);        // Set (x,y,z) position of container
  88.         void    SetRotation(float angle);    // (OGL) Sets the current x rotation angle
  89.     
  90.         
  91.     //---------------------- Private -------------------------
  92.  
  93.     private:
  94.  
  95.         // Data Members
  96.         char    CurAction;            // (OGL) The current action being performed by the container 
  97.         char    Matrix[36][20];        // Stores the container data
  98.         char    NoOfLinesFound;        // Holds prev amount of lines detected
  99.         float    xCurRotation;        // (OGL) Current x rotation angle of container
  100.         float    xNewRotation;        // (OGL) New Rotation anle ensures smooth rotation
  101.  
  102.         // Member Funtions
  103.         void    ClearLine(char y);    // Clears the line at y and moves all the rows above it one down
  104.         void    Hover();            // Makes the container appear to hover
  105.         bool    Line(char y);        // Returns true if there is a line at y
  106.         float    Random();            // Used for hovering in random directions
  107.         char    WrapX(char x);        // Wraps around in container x-axis 
  108.  
  109. };//Class Container
  110.  
  111. #endif;